package com.xihua.sx.controller;


import com.xihua.sx.pojo.PageData;
import com.xihua.sx.pojo.Driver;
import com.xihua.sx.service.IDriverService;
import com.xihua.sx.utils.ResponseMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2023-06-16
 */
@RestController
@RequestMapping("/driver")
public class DriverController {

    @Autowired
    private IDriverService driverService;

    /**
     * 分页查询驾驶员信息
     * @param pageData
     * @return
     */
    @RequestMapping(value = "/driverList",method = RequestMethod.GET)
    public ResponseMessage driverList(PageData pageData){
        System.out.println(pageData.toString());
        return driverService.driverList(pageData);
    }

    /**
     * 根据id查询驾驶员信息，测试用的，后期删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/driverOne",method = RequestMethod.GET)
    public ResponseMessage driverOne(Integer id){
        return driverService.driverOne(id);
    }

    /**
     * 新增驾驶员信息
     * @param driver
     * @return
     */
    @RequestMapping(value = "/insertDriver",method = RequestMethod.PUT)
    public ResponseMessage insertDriver(@RequestBody Driver driver){
        System.out.println(driver.toString());
        return driverService.insertDriver(driver);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteDriver",method = RequestMethod.DELETE)
    public ResponseMessage deleteDriver(Integer id){
        return driverService.deleteDriver(id);
    }

    /**
     * 修改
     * @param driver
     * @return
     */
    @RequestMapping(value = "/updateDriver",method = RequestMethod.POST)
    public ResponseMessage updateDriver(@RequestBody Driver driver){
        return driverService.updateDriver(driver);
    }

    /**
     * 模糊查询
     * @param driver
     * @return
     */
    @RequestMapping(value = "/selectLike",method = RequestMethod.POST)
    public ResponseMessage selectLike(@RequestBody Driver driver){
        return driverService.selectLike(driver);
    }



}
